package org.tagewerk.bookinfo.model;

import java.util.Arrays;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.appfuse.model.BaseObject;

@Entity
@Table(name = "book")
public class Book extends BaseObject {
	
	private Long id;
	private String title;
	private String textAbstract;
	private String author;
	private String translator;
	private String binding;
	private String condition;
	private String isbn_10;
	private String isbn_13;
	private String edition;
	private String publisher;
	private String productGroup;
	private String productCategory;
	private Date publicationDate;
	private String language_iso;
	private boolean original_language;
//	private String translation_languages_avail_iso;
//	private String amazonPrice;
//	private String lowestAmazonPrice;
	private int pageAmount;
	private int weight;
	private int height;
	private int length;
	private int width;
	private byte[] imageSmall;
	private byte[] imageMedium;
	private byte[] imageLarge;
	
	@Id @GeneratedValue(strategy = GenerationType.AUTO)
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	@Column(name="title", length=255)
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	
	@Column(name="translator")
	public String getTranslator() {
		return translator;
	}
	public void setTranslator(String translator) {
		this.translator = translator;
	}
	
	@Column(name="binding")
	public String getBinding() {
		return binding;
	}
	public void setBinding(String binding) {
		this.binding = binding;
	}
	
	@Column(name="book_condition")
	public String getCondition() {
		return condition;
	}
	public void setCondition(String condition) {
		this.condition = condition;
	}
	
	@Column(name="isbn_10")
	public String getIsbn_10() {
		return isbn_10;
	}
	public void setIsbn_10(String isbn_10) {
		this.isbn_10 = isbn_10;
	}
	
	@Column(name="isbn_13")
	public String getIsbn_13() {
		return isbn_13;
	}
	public void setIsbn_13(String isbn_13) {
		this.isbn_13 = isbn_13;
	}
	
	@Column(name="edition")
	public String getEdition() {
		return edition;
	}
	public void setEdition(String edition) {
		this.edition = edition;
	}
	
	@Column(name="publisher")
	public String getPublisher() {
		return publisher;
	}
	public void setPublisher(String publisher) {
		this.publisher = publisher;
	}

	@Column(name="publication_date")
	public Date getPublicationDate() {
		return publicationDate;
	}
	public void setPublicationDate(Date publicationDate) {
		this.publicationDate = publicationDate;
	}
	
	@Column(name="language_iso")
	public String getLanguage_iso() {
		return language_iso;
	}
	public void setLanguage_iso(String language_iso) {
		this.language_iso = language_iso;
	}
	
	@Column(name="original_language")
	public boolean isOriginal_language() {
		return original_language;
	}
	public void setOriginal_language(boolean original_language) {
		this.original_language = original_language;
	}
	
	@Column(name="page_amount")
	public int getPageAmount() {
		return pageAmount;
	}
	public void setPageAmount(int pageAmount) {
		this.pageAmount = pageAmount;
	}
	
	@Column(name="weight")
	public int getWeight() {
		return weight;
	}
	public void setWeight(int weight) {
		this.weight = weight;
	}
	
	@Column(name="height")
	public int getHeight() {
		return height;
	}
	public void setHeight(int height) {
		this.height = height;
	}
	
	@Column(name="length")
	public int getLength() {
		return length;
	}
	public void setLength(int length) {
		this.length = length;
	}
	
	@Column(name="width")
	public int getWidth() {
		return width;
	}
	public void setWidth(int width) {
		this.width = width;
	}
	
	@Column(name="image_small")
	public byte[] getImageSmall() {
		return imageSmall;
	}
	public void setImageSmall(byte[] imageSmall) {
		this.imageSmall = imageSmall;
	}
	
	@Column(name="image_medium")
	public byte[] getImageMedium() {
		return imageMedium;
	}
	public void setImageMedium(byte[] imageMedium) {
		this.imageMedium = imageMedium;
	}
	
	@Column(name="image_large")
	public byte[] getImageLarge() {
		return imageLarge;
	}
	public void setImageLarge(byte[] imageLarge) {
		this.imageLarge = imageLarge;
	}
	
	@Column(name="text_abstract")
	public String getTextAbstract() {
		return textAbstract;
	}
	public void setTextAbstract(String textAbstract) {
		this.textAbstract = textAbstract;
	}
	
	@Column(name="author")
	public String getAuthor() {
		return author;
	}
	public void setAuthor(String author) {
		this.author = author;
	}
	
	@Column(name="product_group")
	public String getProductGroup() {
		return productGroup;
	}
	public void setProductGroup(String productGroup) {
		this.productGroup = productGroup;
	}
	
	@Column(name="product_category")
	public String getProductCategory() {
		return productCategory;
	}
	public void setProductCategory(String productCategory) {
		this.productCategory = productCategory;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 0;
		result = prime * result + ((author == null) ? 0 : author.hashCode());
		result = prime * result + ((binding == null) ? 0 : binding.hashCode());
		result = prime * result
				+ ((condition == null) ? 0 : condition.hashCode());
		result = prime * result + ((edition == null) ? 0 : edition.hashCode());
		result = prime * result + height;
		result = prime * result + Arrays.hashCode(imageLarge);
		result = prime * result + Arrays.hashCode(imageMedium);
		result = prime * result + Arrays.hashCode(imageSmall);
		result = prime * result + ((isbn_10 == null) ? 0 : isbn_10.hashCode());
		result = prime * result + ((isbn_13 == null) ? 0 : isbn_13.hashCode());
		result = prime * result
				+ ((language_iso == null) ? 0 : language_iso.hashCode());
		result = prime * result + length;
		result = prime * result + (original_language ? 1231 : 1237);
		result = prime * result + pageAmount;
		result = prime * result
				+ ((productCategory == null) ? 0 : productCategory.hashCode());
		result = prime * result
				+ ((productGroup == null) ? 0 : productGroup.hashCode());
		result = prime * result
				+ ((publicationDate == null) ? 0 : publicationDate.hashCode());
		result = prime * result
				+ ((publisher == null) ? 0 : publisher.hashCode());
		result = prime * result
				+ ((textAbstract == null) ? 0 : textAbstract.hashCode());
		result = prime * result + ((title == null) ? 0 : title.hashCode());
		result = prime * result
				+ ((translator == null) ? 0 : translator.hashCode());
		result = prime * result + weight;
		result = prime * result + width;
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (getClass() != obj.getClass())
			return false;
		Book other = (Book) obj;
		if (author == null) {
			if (other.author != null)
				return false;
		} else if (!author.equals(other.author))
			return false;
		if (binding == null) {
			if (other.binding != null)
				return false;
		} else if (!binding.equals(other.binding))
			return false;
		if (condition == null) {
			if (other.condition != null)
				return false;
		} else if (!condition.equals(other.condition))
			return false;
		if (edition == null) {
			if (other.edition != null)
				return false;
		} else if (!edition.equals(other.edition))
			return false;
		if (height != other.height)
			return false;
		if (!Arrays.equals(imageLarge, other.imageLarge))
			return false;
		if (!Arrays.equals(imageMedium, other.imageMedium))
			return false;
		if (!Arrays.equals(imageSmall, other.imageSmall))
			return false;
		if (isbn_10 == null) {
			if (other.isbn_10 != null)
				return false;
		} else if (!isbn_10.equals(other.isbn_10))
			return false;
		if (isbn_13 == null) {
			if (other.isbn_13 != null)
				return false;
		} else if (!isbn_13.equals(other.isbn_13))
			return false;
		if (language_iso == null) {
			if (other.language_iso != null)
				return false;
		} else if (!language_iso.equals(other.language_iso))
			return false;
		if (length != other.length)
			return false;
		if (original_language != other.original_language)
			return false;
		if (pageAmount != other.pageAmount)
			return false;
		if (productCategory == null) {
			if (other.productCategory != null)
				return false;
		} else if (!productCategory.equals(other.productCategory))
			return false;
		if (productGroup == null) {
			if (other.productGroup != null)
				return false;
		} else if (!productGroup.equals(other.productGroup))
			return false;
		if (publicationDate == null) {
			if (other.publicationDate != null)
				return false;
		} else if (!publicationDate.equals(other.publicationDate))
			return false;
		if (publisher == null) {
			if (other.publisher != null)
				return false;
		} else if (!publisher.equals(other.publisher))
			return false;
		if (textAbstract == null) {
			if (other.textAbstract != null)
				return false;
		} else if (!textAbstract.equals(other.textAbstract))
			return false;
		if (title == null) {
			if (other.title != null)
				return false;
		} else if (!title.equals(other.title))
			return false;
		if (translator == null) {
			if (other.translator != null)
				return false;
		} else if (!translator.equals(other.translator))
			return false;
		if (weight != other.weight)
			return false;
		if (width != other.width)
			return false;
		return true;
	}
	
	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return null;
	}
 
	

}
